
<%@ include file="/common/taglibs.jsp"%>
<!--分页查询共用的页面-->
<%@ include file="/common/common.jsp"%>
<%@ page language="java" pageEncoding="UTF-8"%>

<script type="text/javascript" src="<%=jsPath%>/jquery/jquery.timers.js"></script><!--定时器-->
<script type="text/javascript" src="<%=jsPath%>/terminalCommand.js?v=32"></script><!--终端命令结果查询-->
	
<script>
	/*
	修改代码：
	1.新定义变量TerminalCommmand，为命令支持变量
	2.重定义id：
	原：null		现：savpCommandMsg
	原：null		现：savpBtnQuery
	原：		现：
	*/

	var tc2SpecialAlarmVideoParam = new TerminalCommand2();
    var timerName = "specialAlarmVideoParamTimer";
    ///////////////////////////////////////////////////////////////
    tc2SpecialAlarmVideoParam.messageDiv = $("#savpCommandMsg");
	tc2SpecialAlarmVideoParam.timerName = timerName;
	//tc2SpecialAlarmVideoParam.commandButton = $("#savpBtnQuery");

    //当查询终端参数命令执行成功时
    function onQueryCommandSuccess(result){
        if (result.success) {
            var p = result.data[0];
            var strArray = p.value.split(",");
            var i = 0;
            $("#storeThreshold").val(strArray[i++]);
            $("#duration").val(strArray[i++]);
            $("#advanceTime").val(strArray[i++]);
        }

    }
    /**
     * 下发参数查询指令
     */
    function sendParamQueryCommand()
    {
        operation = "query";
        var url = "<%=ApplicationPath%>/videoTerminalParam/sendParamQueryCommand.action";
        var param = {paramId : 0x0079,vehicleId:${vehicleId}};
        $.getJSON(url, param, function(result)
        {
            if (result.success) {
                var commandId = result.data; //下发成功后，获取到命令Id
                tc2SpecialAlarmVideoParam.commandButton = $("#savpBtnQuery");
                var url = "<%=ApplicationPath%>/terminalParam/queryTerminalParam.action";
                tc2SpecialAlarmVideoParam.times=190;
                tc2SpecialAlarmVideoParam.startQueryResult(commandId,url,onQueryCommandSuccess);//命令下发成功,根据命令id,开始尝试获取检索结果

            }else {
                $("#savpCommandMsg").html("提交失败! 错误原因：" + (result.message ? result.message : result.Data));
                //停止所有的在$('body')上定时器
                $('#savpBody').stopTime (timerName);
            }
        });
    }

$().ready(function() {
	 $("#savpEntityForm").validate(); //初始化验证信息
	 Utility.ajaxSubmitForm("savpEntityForm", {
						 success:function(responseText)
						 {
							   var result = responseText;
								if (result.success) {
									 var commandId = result.data; //下发成功后，获取到命令Id
									 tc2SpecialAlarmVideoParam.commandButton = $("#savpBtnConfig");
									 tc2SpecialAlarmVideoParam.startQueryResult(commandId);//命令下发成功,根据命令id,开始尝试获取检索结果
								}
								else {
									$("#savpCommandMsg").html("提交失败! 错误原因：" + (result.message ? result.message : result.Data));
									//停止所有的在$('body')上定时器  
									$('#savpBody').stopTime (timerName);  
								  }
						 }
	 });
    $("#savpBtnQuery").click(function()
    {
        sendParamQueryCommand();//下发参数查询命令
    });
});
</script>
 <BODY id="savpBody">
	<form id="savpEntityForm" name="savpEntityForm" 
			action='<%=ApplicationPath%>/videoTerminalParam/configSpecialAlarmVideoParam.action' method="POST">
				<!--超速设置-->
        <input type="hidden"  name="operation"  id="operation" value="modify"/>
        <input type="hidden"  name="vehicleId"  id="vehicleId" value="${vehicleId}"/>
  <table width="100%"  class="TableBlock">
					<tbody><tr>
						<td colspan="2" style="font-weight: bold; background: #EFEFEF;" height="25">特殊报警录像参数定义
						<span style="color:red;background:blue;">${message}</span>
						</td>
					</tr>
					
					<tr>
						<td align="right">特殊报警录像存储阈值
							:</td>
						<td>
						<input type="text" id="storeThreshold"   name="storeThreshold" maxlength="16" size="20"  value="20"
						   class="required digits">(占用主存储阈值百分比)
						  </td>
					</tr>
					<tr>
						<td align="right">特殊报警录像持续时间:</td>
						<td >
						<input type="text" id="duration"   name="duration" maxlength="16" size="20"  value="5"
						   class="required digits">(分钟)
						</td>
					</tr>
					<tr>
						<td align="right">特殊报警标识起始时间:</td>
						<td >
							<input type="text" id="advanceTime"   name="advanceTime" maxlength="16" size="20"  value="1"
								   class="required digits">(分钟)
						</td>
					</tr>
					<tr>

						<td colspan=2 align="center">

							<button id="savpBtnConfig" type="submit" class="button green medium sendjson" ><i class="fa fa-cog" style="margin-right:3px;"></i> 设置参数</button>

							<button id="savpBtnQuery" type="button" class="button blue medium " ><i class="fa fa-reply-all" style="margin-right:3px;"></i> 查询参数</button>

							<span id="savpCommandMsg" class="commandMsg"></span></td>
						
					</tr>

				
					
				</tbody></table>
				</form>
 </BODY>
</HTML>
